/*** Eclipse Class Decompiler plugin, copyright (c) 2012 Chao Chen (cnfree2000@hotmail.com) ***/
package com.qihoo.gamecenter.sdk.common.i;

import java.io.UnsupportedEncodingException;

public class a {
    public static byte[] a(String paramString, int paramInt) {
        return a(paramString.getBytes(), paramInt);
    }

    public static byte[] a(byte[] paramArrayOfByte, int paramInt) {
        return a(paramArrayOfByte, 0, paramArrayOfByte.length, paramInt);
    }

    public static byte[] a(byte[] paramArrayOfByte, int paramInt1, int paramInt2, int paramInt3) {
        b localb = new b(paramInt3, new byte[paramInt2 * 3 / 4]);
        if (!(localb.a(paramArrayOfByte, paramInt1, paramInt2, true)))
            throw new IllegalArgumentException("bad base-64");
        if (localb.b == localb.a.length)
            return localb.a;
        byte[] arrayOfByte = new byte[localb.b];
        System.arraycopy(localb.a, 0, arrayOfByte, 0, localb.b);
        return arrayOfByte;
    }

    public static String b(byte[] paramArrayOfByte, int paramInt) {
        try {
            return new String(c(paramArrayOfByte, paramInt), "US-ASCII");
        } catch (UnsupportedEncodingException localUnsupportedEncodingException) {
            throw new AssertionError(localUnsupportedEncodingException);
        }
    }

    public static byte[] c(byte[] paramArrayOfByte, int paramInt) {
        return b(paramArrayOfByte, 0, paramArrayOfByte.length, paramInt);
    }

    public static byte[] b(byte[] paramArrayOfByte, int paramInt1, int paramInt2, int paramInt3) {
        c localc = new c(paramInt3, null);
        int i = paramInt2 / 3 * 4;
        if (localc.d)
            if (paramInt2 % 3 > 0)
                i += 4;
            else
                switch (paramInt2 % 3) {
                case 0:
                    break;
                case 1:
                    i += 2;
                    break;
                case 2:
                    i += 3;
                }
        if ((localc.e) && (paramInt2 > 0))
            i += ((paramInt2 - 1) / 57 + 1) * ((localc.f) ? 2 : 1);
        localc.a = new byte[i];
        localc.a(paramArrayOfByte, paramInt1, paramInt2, true);
        if ((!(a)) && (localc.b != i))
            throw new AssertionError();
        return localc.a;
    }

    static class c extends a.a {
        private static final byte[] h;
        private static final byte[] i;
        private final byte[] j;
        int c;
        private int k;
        public final boolean d;
        public final boolean e;
        public final boolean f;
        private final byte[] l;

        public c(int paramInt, byte[] paramArrayOfByte) {
            this.a = paramArrayOfByte;
            this.d = ((paramInt & 0x1) == 0);
            this.e = ((paramInt & 0x2) == 0);
            this.f = ((paramInt & 0x4) != 0);
            this.l = (((paramInt & 0x8) == 0) ? h : i);
            this.j = new byte[2];
            this.c = 0;
            this.k = ((this.e) ? 19 : -1);
        }

        public boolean a(byte[] paramArrayOfByte, int paramInt1, int paramInt2, boolean paramBoolean) {
            byte[] arrayOfByte1 = this.l;
            byte[] arrayOfByte2 = this.a;
            int i1 = 0;
            int i2 = this.k;
            int i3 = paramInt1;
            paramInt2 += paramInt1;
            int i4 = -1;
            switch (this.c) {
            case 0:
                break;
            case 1:
                if (i3 + 2 <= paramInt2) {
                    i4 = (this.j[0] & 0xFF) << 16 | (paramArrayOfByte[(i3++)] & 0xFF) << 8 | paramArrayOfByte[(i3++)]
                            & 0xFF;
                    this.c = 0;
                }
                break;
            case 2:
                if (i3 + 1 <= paramInt2) {
                    i4 = (this.j[0] & 0xFF) << 16 | (this.j[1] & 0xFF) << 8 | paramArrayOfByte[(i3++)] & 0xFF;
                    this.c = 0;
                }
            }
            if (i4 != -1) {
                arrayOfByte2[(i1++)] = arrayOfByte1[(i4 >> 18 & 0x3F)];
                arrayOfByte2[(i1++)] = arrayOfByte1[(i4 >> 12 & 0x3F)];
                arrayOfByte2[(i1++)] = arrayOfByte1[(i4 >> 6 & 0x3F)];
                arrayOfByte2[(i1++)] = arrayOfByte1[(i4 & 0x3F)];
                if (--i2 == 0) {
                    if (this.f)
                        arrayOfByte2[(i1++)] = 13;
                    arrayOfByte2[(i1++)] = 10;
                }
            }
            for (i2 = 19; i3 + 3 <= paramInt2; i2 = 19) {
                do {
                    i4 = (paramArrayOfByte[i3] & 0xFF) << 16 | (paramArrayOfByte[(i3 + 1)] & 0xFF) << 8
                            | paramArrayOfByte[(i3 + 2)] & 0xFF;
                    arrayOfByte2[i1] = arrayOfByte1[(i4 >> 18 & 0x3F)];
                    arrayOfByte2[(i1 + 1)] = arrayOfByte1[(i4 >> 12 & 0x3F)];
                    arrayOfByte2[(i1 + 2)] = arrayOfByte1[(i4 >> 6 & 0x3F)];
                    arrayOfByte2[(i1 + 3)] = arrayOfByte1[(i4 & 0x3F)];
                    i3 += 3;
                    i1 += 4;
                } while (--i2 != 0);
                if (this.f)
                    arrayOfByte2[(i1++)] = 13;
                arrayOfByte2[(i1++)] = 10;
            }
            if (paramBoolean) {
                int i5;
                if (i3 - this.c == paramInt2 - 1) {
                    i5 = 0;
                    i4 = (((this.c > 0) ? this.j[(i5++)] : paramArrayOfByte[(i3++)]) & 0xFF) << 4;
                    this.c -= i5;
                    arrayOfByte2[(i1++)] = arrayOfByte1[(i4 >> 6 & 0x3F)];
                    arrayOfByte2[(i1++)] = arrayOfByte1[(i4 & 0x3F)];
                    if (this.d) {
                        arrayOfByte2[(i1++)] = 61;
                        arrayOfByte2[(i1++)] = 61;
                    }
                    if (this.e) {
                        if (this.f)
                            arrayOfByte2[(i1++)] = 13;
                        arrayOfByte2[(i1++)] = 10;
                    }
                }
                else if (i3 - this.c == paramInt2 - 2) {
                    i5 = 0;
                    i4 = (((this.c > 1) ? this.j[(i5++)] : paramArrayOfByte[(i3++)]) & 0xFF) << 10
                            | (((this.c > 0) ? this.j[(i5++)] : paramArrayOfByte[(i3++)]) & 0xFF) << 2;
                    this.c -= i5;
                    arrayOfByte2[(i1++)] = arrayOfByte1[(i4 >> 12 & 0x3F)];
                    arrayOfByte2[(i1++)] = arrayOfByte1[(i4 >> 6 & 0x3F)];
                    arrayOfByte2[(i1++)] = arrayOfByte1[(i4 & 0x3F)];
                    if (this.d)
                        arrayOfByte2[(i1++)] = 61;
                    if (this.e) {
                        if (this.f)
                            arrayOfByte2[(i1++)] = 13;
                        arrayOfByte2[(i1++)] = 10;
                    }
                }
                else if ((this.e) && (i1 > 0) && (i2 != 19)) {
                    if (this.f)
                        arrayOfByte2[(i1++)] = 13;
                    arrayOfByte2[(i1++)] = 10;
                }
                if ((!(g)) && (this.c != 0))
                    throw new AssertionError();
                if ((!(g)) && (i3 != paramInt2))
                    throw new AssertionError();
            }
            else if (i3 == paramInt2 - 1) {
                this.j[(this.c++)] = paramArrayOfByte[i3];
            }
            else if (i3 == paramInt2 - 2) {
                this.j[(this.c++)] = paramArrayOfByte[i3];
                this.j[(this.c++)] = paramArrayOfByte[(i3 + 1)];
            }
            this.b = i1;
            this.k = i2;
            return true;
        }

        static {
            h = new byte[] { 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
                    87, 88, 89, 90, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113,
                    114, 115, 116, 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 43, 47 };
            i = new byte[] { 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
                    87, 88, 89, 90, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113,
                    114, 115, 116, 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 45, 95 };
        }
    }

    static class b extends a.a {
        private static final int[] c = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
                -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1,
                -1, -1, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -2, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7,
                8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, -1, 26, 27,
                28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1,
                -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
                -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
                -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
                -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
                -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
                -1 };
        private static final int[] d = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
                -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
                62, -1, -1, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -2, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7,
                8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, 63, -1, 26, 27,
                28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1,
                -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
                -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
                -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
                -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
                -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
                -1 };
        private int e;
        private int f;
        private final int[] g;

        public b(int paramInt, byte[] paramArrayOfByte) {
            this.a = paramArrayOfByte;
            this.g = (((paramInt & 0x8) == 0) ? c : d);
            this.e = 0;
            this.f = 0;
        }

        public boolean a(byte[] paramArrayOfByte, int paramInt1, int paramInt2, boolean paramBoolean) {
            if (this.e == 6)
                return false;
            int i = paramInt1;
            paramInt2 += paramInt1;
            int j = this.e;
            int k = this.f;
            int l = 0;
            byte[] arrayOfByte = this.a;
            int[] arrayOfInt = this.g;
            while (i < paramInt2) {
                if (j == 0) {
                    while ((i + 4 <= paramInt2)
                            && ((k = arrayOfInt[(paramArrayOfByte[i] & 0xFF)] << 18
                                    | arrayOfInt[(paramArrayOfByte[(i + 1)] & 0xFF)] << 12
                                    | arrayOfInt[(paramArrayOfByte[(i + 2)] & 0xFF)] << 6
                                    | arrayOfInt[(paramArrayOfByte[(i + 3)] & 0xFF)]) >= 0)) {
                        arrayOfByte[(l + 2)] = (byte) k;
                        arrayOfByte[(l + 1)] = (byte) (k >> 8);
                        arrayOfByte[l] = (byte) (k >> 16);
                        l += 3;
                        i += 4;
                    }
                    if (i >= paramInt2)
                        break;
                }
                int i1 = arrayOfInt[(paramArrayOfByte[(i++)] & 0xFF)];
                switch (j) {
                case 0:
                    if (i1 >= 0) {
                        k = i1;
                        ++j;
                    }
                    else if (i1 != -1) {
                        this.e = 6;
                        return false;
                    }
                case 1:
                    if (i1 >= 0) {
                        k = k << 6 | i1;
                        ++j;
                    }
                    else if (i1 != -1) {
                        this.e = 6;
                        return false;
                    }
                case 2:
                    if (i1 >= 0) {
                        k = k << 6 | i1;
                        ++j;
                    }
                    else if (i1 == -2) {
                        arrayOfByte[(l++)] = (byte) (k >> 4);
                        j = 4;
                    }
                    else if (i1 != -1) {
                        this.e = 6;
                        return false;
                    }
                case 3:
                    if (i1 >= 0) {
                        k = k << 6 | i1;
                        arrayOfByte[(l + 2)] = (byte) k;
                        arrayOfByte[(l + 1)] = (byte) (k >> 8);
                        arrayOfByte[l] = (byte) (k >> 16);
                        l += 3;
                        j = 0;
                    }
                    else if (i1 == -2) {
                        arrayOfByte[(l + 1)] = (byte) (k >> 2);
                        arrayOfByte[l] = (byte) (k >> 10);
                        l += 2;
                        j = 5;
                    }
                    else if (i1 != -1) {
                        this.e = 6;
                        return false;
                    }
                case 4:
                    if (i1 == -2) {
                        ++j;
                    }
                    else if (i1 != -1) {
                        this.e = 6;
                        return false;
                    }
                case 5:
                    if (i1 != -1) {
                        this.e = 6;
                        return false;
                    }
                }
            }
            if (!(paramBoolean)) {
                this.e = j;
                this.f = k;
                this.b = l;
                return true;
            }
            switch (j) {
            case 0:
                break;
            case 1:
                this.e = 6;
                return false;
            case 2:
                arrayOfByte[(l++)] = (byte) (k >> 4);
                break;
            case 3:
                arrayOfByte[(l++)] = (byte) (k >> 10);
                arrayOfByte[(l++)] = (byte) (k >> 2);
                break;
            case 4:
                this.e = 6;
                return false;
            case 5:
            }
            this.e = j;
            this.b = l;
            return true;
        }
    }

    static abstract class a {
        public byte[] a;
        public int b;
    }
}